/*
 *Copyright (c) [2019] [name of copyright holder]
 *[Software Name] is licensed under the Mulan PSL v1.
 *You can use this software according to the terms and conditions of the Mulan PSL v1.
 *You may obtain a copy of Mulan PSL v1 at:
 *http://license.coscl.org.cn/MulanPSL
 *THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 *IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 *PURPOSE.
 *See the Mulan PSL v1 for more details.
 */

/*!
 * \autor captainpeng
 * \date 2019-5-15
 * \update 2019-5-15
 * \version 1.0
 * \copyright
 */

#ifndef MY_MEMLISTNODE_HPP
#define MY_MEMLISTNODE_HPP

#include "memFunc.hpp"

namespace my{
    
    class memListNode{
    public:
        // using fnType=void(*)(void *);
        using fnType = memFreeFunc;
        void * mPower; // 主权指针的地址
        void * mValue; // 分配内存的地址
        int mCount; // 计数器
        int mSize; // 分配内存地址的大小
        fnType mFree; //进行 delete 的函数指针
        memListNode * mNext; // 下一个元素
	
        memListNode():mValue(nullptr),mSize(-1),mCount(0){}

        // 交换主权指针地址，分配地址与大小并不会交换
        void swapPower(memListNode & node){
            void * tmp;
            tmp=mPower;
            mPower=node.mPower;
            node.mPower=tmp;
        }
    };

}

#endif
